<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
selection_test(
    '<div contenteditable>|</div>',
    selection => selection.document.execCommand('insertImage', false,
        '../resources/abe.png'),
    [
        '<div contenteditable>',
            '<img src="../resources/abe.png">|',
        '</div>',
    ],
    'insertImage with valid image');

selection_test(
    [
        '<div contenteditable>',
            '<img src="../resources/abe.png">|',
        '</div>',
    ],
    selection => selection.document.execCommand('insertImage', false,
        '../resources/do-not-name-an-image-this.jpg'),
    [
        '<div contenteditable>',
            '<img src="../resources/abe.png">',
            '<img src="../resources/do-not-name-an-image-this.jpg">|',
        '</div>',
    ],
    'insertImage with non-existent image');
</script>
